class Solution {//用最少数量的箭引爆气球
public:
    int findMinArrowShots(vector<vector<int>>& points) {
        vector<vector<int>> shoot;
        sort(points.begin(),points.end(),[](vector<int>&lhs,vector<int>&rhs){
            return lhs[0]<rhs[0];
        });
        shoot.push_back(points[0]);
        int n=points.size();
        int cur=0;
        for(int i=1;i<n;i++){
            int begin1=shoot[cur][0],end1=shoot[cur][1];
            int begin2=points[i][0],end2=points[i][1];
            if(begin2<=end1){
                int left=max(begin1,begin2);
                int right=min(end1,end2);
                shoot[cur]={left,right};
            }
            else{
                shoot.push_back({begin2,end2});
                cur++;
            }
        }
        return shoot.size();
    }
};